-- checkStock.lua (使用数字存储库存)
local key = KEYS[1]
local quantity = tonumber(ARGV[1])

local current_stock = tonumber(redis.call('GET', key))


if not current_stock or current_stock < quantity then
    return 0 -- 库存不足
else
    redis.call('DECRBY', key, quantity)
    return 1 -- 扣减成功
end